class BusinessException(Exception):
    """业务异常基类"""
    def __init__(self, code=500, message="业务处理异常"):
        self.code = code
        self.message = message
        super().__init__(message)

    def to_dict(self):
        return {
            "code": self.code,
            "message": self.message
        }

# 常用业务异常子类示例
class InvalidParameterException(BusinessException):
    """参数无效异常"""
    def __init__(self, message="参数无效"):
        super().__init__(400, message)

class ResourceNotFoundException(BusinessException):
    """资源不存在异常"""
    def __init__(self, message="资源不存在"):
        super().__init__(404, message)

class PermissionDeniedException(BusinessException):
    """权限不足异常"""
    def __init__(self, message="权限不足"):
        super().__init__(403, message)